#ifndef SCRIPTEDITVIEW_H
#define SCRIPTEDITVIEW_H

#include <QPlainTextEdit>
#include <QTimeLine>

class QScriptHighLight;
class ScriptEditView;

class LineWidget : public QWidget
{
    Q_OBJECT
public:
    LineWidget(QTextDocument *document,QWidget* parent=0);
protected:
    void mousePressEvent(QMouseEvent *);
    QSize   sizeHint()const;
    void paintEvent(QPaintEvent *);
protected:
    ScriptEditView  *editor()const;
protected:
    QTextDocument *m_document;

};

class ScriptEditView : public QPlainTextEdit
{
    Q_OBJECT
public:
    ScriptEditView(QWidget* parent=0);
    QList<QAction*> getActions();

    int extraAreaWidth() const;

    void painteLineWidget(QPainter *p);
    void extraAreaMouseEvent(QMouseEvent *e);

    void selectIndex(const QString text);

public slots:
    void    findNext();
    void    findPrev();

    void    replace(const QString &text);
    void    replaceNext(const QString &text);
    void    replaceAll(const QString &text);

    void    keyPressEvent(QKeyEvent *e);
protected:
    void resizeEvent(QResizeEvent *e);
    void paintEvent(QPaintEvent *e);
protected slots:
    void    zoomOut();
    void    zoomIn();

    void    clipboardDataChanged();
    void    updateLineWidget();
    void    updateExtraAreaWidth();

    void    positionChanged();
    void    finish();

protected:
    QScriptHighLight    *m_highlight;
    QList<QAction*>     m_actions;
    QAction*            m_pasteAction;
    LineWidget          *m_lineWidget;
    QString             m_findText;
    QTimeLine           *m_timeLine;
    bool                m_needShowCursor;
};

#endif // SCRIPTEDITVIEW_H
